package com.ithe;

import java.awt.desktop.SystemSleepEvent;
import java.util.ArrayList;
import java.util.LinkedList;

public class LinkListDemo {
    public static void main(String []args) {
        LinkedList<String> list = new LinkedList<>();
        list.addFirst("李明");
        list.addFirst("小明");
        list.addLast("王二");
        list.addLast("李二");
        list.addLast("天天");

        String s = list.get(3);//O(n)
        ArrayList<String> arrayList = new ArrayList<>();
        arrayList.get(3);//O(1)查询效率更快

        String first = list.getFirst();
        String last = list.getLast();
        System.out.println(first);
        System.out.println(last);

        String removefirst = list.removeFirst();
        String removelast = list.removeLast();
        System.out.println(removefirst);
        System.out.println(removelast);
        System.out.println(list);
    }
}
